package com.xiatao.controller;

import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.ServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSONObject;
import com.xiatao.mapper.demoMapper;
import com.xiatao.service.AbbService;

@RestController
@RequestMapping("/demo")
//@CrossOrigin(origins = "http://localhost:8081")
public class demoController {
	@Autowired
	demoMapper demoMapper;
	@Autowired
	AbbService abbService;
	@Transactional
	@RequestMapping(value = "/hello", method = { RequestMethod.POST, RequestMethod.GET })
    public Map<String,Object> index(@RequestBody String params,ServletRequest req) throws UnsupportedEncodingException {
		String entity=req.getParameter("filter");
		Map<String,Object> returnMap = new HashMap<>();
		returnMap=abbService.handleAbbMsg(entity);
//		String taskName1 = java.net.URLDecoder.decode(params,"UTF-8");
		return returnMap;
    }
	
	@RequestMapping(value = "/nextData", method = { RequestMethod.POST, RequestMethod.GET })
    public Map<String,Object> nextData(@RequestBody String params,ServletRequest req) throws UnsupportedEncodingException {
		String entity=req.getParameter("filter");
		Map<String,Object> returnMap = new HashMap<>();
		returnMap=abbService.queryNext(entity);
//		String taskName1 = java.net.URLDecoder.decode(params,"UTF-8");
		return returnMap;
    }
	
	@RequestMapping(value = "/proData", method = { RequestMethod.POST, RequestMethod.GET })
    public Map<String,Object> proData(@RequestBody String params,ServletRequest req) throws UnsupportedEncodingException {
		String entity=req.getParameter("filter");
		Map<String,Object> returnMap = new HashMap<>();
		returnMap=abbService.queryPro(entity);
//		String taskName1 = java.net.URLDecoder.decode(params,"UTF-8");
		return returnMap;
    }
}
